package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zer extends zep {
   private zagu c;
   private int d;
   private short e;
   private boolean f;
   private boolean g;
   private long h;
   private long i;
   private zaar j;
   private zaar k;
   private zagu[] l;
   private long[] m;
   private long[] n;

   zer(zaaz var1, zfv var2, zaay var3) {
      super(var1);
      zaar var4 = null;
      zaar var5 = null;
      zagu[] var6 = null;
      long[] var7 = null;
      long[] var8 = null;
      long var9 = -1L;
      long var11 = -1L;
      boolean var13 = false;
      boolean var14 = false;
      int var15 = 0;
      int var16 = 0;
      if (var2 == null) {
         this.c = zzk.a;
      } else if (var2.c == 5) {
         ArrayList var17 = null;
         zyi var18 = (zyi)var2.d;
         this.c = ((zyi)var2.d).a(var3, true);
         HashMap var19;
         if (var1.d()) {
            var15 = this.a.StartRow - 1;
            var16 = this.a.StartColumn - 1;
            if (!var1.b() || !var1.c()) {
               var17 = new ArrayList(8);
               if (!var1.b()) {
                  var19 = new HashMap();
                  var4 = new zaar();
                  this.a(this.c, var4, var1.b, var1.c, var3, var17, 0, var19);
                  var7 = zgj.a(var19);
                  if (var4.a != null) {
                     var4.a = null;
                     var13 = true;
                     var9 = Cell.a(var3.n, var1.b, var1.c);
                  } else {
                     var4 = null;
                     if (var7 != null) {
                        var13 = true;
                        var9 = Cell.a(var3.n, var1.b, var1.c);
                     }
                  }
               }

               if (!var1.c()) {
                  var19 = new HashMap();
                  var5 = new zaar();
                  this.a(this.c, var5, var1.d, var1.e, var3, var17, var17.size(), var19);
                  var8 = zgj.a(var19);
                  if (var5.a != null) {
                     var5.a = null;
                     var14 = true;
                     var11 = Cell.a(var3.n, var1.d, var1.e);
                  } else {
                     var5 = null;
                     if (var8 != null) {
                        var14 = true;
                        var11 = Cell.a(var3.n, var1.d, var1.e);
                     }
                  }
               }
            }
         } else if (var1.e()) {
            var15 = -1;
            var16 = this.a.StartColumn - 1;
            if (!var1.b()) {
               var17 = new ArrayList(8);
               var19 = new HashMap();
               var4 = new zaar();
               this.a(this.c, var4, var1.b, var1.c, var3, var17, 0, var19);
               var7 = zgj.a(var19);
               if (var4.a != null) {
                  var4.a = null;
                  var13 = true;
                  var9 = Cell.a(var3.n, var1.b, var1.c);
               } else {
                  var4 = null;
                  if (var7 != null) {
                     var13 = true;
                     var9 = Cell.a(var3.n, var1.b, var1.c);
                  }
               }
            }
         } else {
            var15 = this.a.StartRow - 1;
            var16 = -1;
            if (!var1.c()) {
               var17 = new ArrayList(8);
               var19 = new HashMap();
               var5 = new zaar();
               this.a(this.c, var5, var1.d, var1.e, var3, var17, 0, var19);
               var8 = zgj.a(var19);
               if (var5.a != null) {
                  var5.a = null;
                  var14 = true;
                  var11 = Cell.a(var3.n, var1.d, var1.e);
               } else {
                  var5 = null;
                  if (var8 != null) {
                     var14 = true;
                     var11 = Cell.a(var3.n, var1.d, var1.e);
                  }
               }
            }
         }

         if (!var13 && !var14) {
            this.c.a(false);
         } else {
            var6 = new zagu[var17.size()];

            for(int var20 = 0; var20 < var6.length; ++var20) {
               var6[var20] = (zagu)var17.get(var20);
            }
         }
      } else {
         this.c = zaaq.a(var2.c, var2.d);
      }

      this.d = var15;
      this.e = (short)var16;
      this.f = var13;
      this.g = var14;
      this.j = var4;
      this.k = var5;
      this.l = var6;
      this.m = var7;
      this.n = var8;
      this.h = var9;
      this.i = var11;
   }

   zagu b(zaay var1) {
      if (!this.f && !this.g) {
         return this.c;
      } else {
         if (this.l != null) {
            zagu[] var2 = this.l;
            int var3 = var2.length;

            for(int var4 = 0; var4 < var3; ++var4) {
               zagu var5 = var2[var4];
               var5.a((zaar)null);
            }
         }

         Object var10 = null;
         Object var11 = null;
         int var6;
         int var7;
         long var8;
         zagu var12;
         long[] var13;
         if (this.f) {
            var12 = zaaq.a(var1.e, this.a.StartRow - 1, var1.h, false, var1);
            if (this.j != null) {
               this.j.a = var12;
            }

            if (this.m != null) {
               if (var1.p.G) {
                  var10 = var1.p.F.get(this.h);
                  var1.p.F.put(this.h, var12);
               } else {
                  if (var1.p.F == null) {
                     var1.p.F = new HashMap();
                  }

                  var1.p.F.put(this.h, var12);
                  var1.p.G = true;
               }

               var13 = this.m;
               var6 = var13.length;

               for(var7 = 0; var7 < var6; ++var7) {
                  var8 = var13[var7];
                  var1.p.g.get(zyi.a(var8)).getCells().b.a(zyi.b(var8)).a((byte)0);
               }
            }
         }

         if (this.g) {
            var12 = zaaq.a(var1.e, var1.g, this.a.StartColumn - 1, false, var1);
            if (this.k != null) {
               this.k.a = var12;
            }

            if (this.n != null) {
               if (var1.p.G) {
                  var11 = var1.p.F.get(this.i);
                  var1.p.F.put(this.i, var12);
               } else {
                  if (var1.p.F == null) {
                     var1.p.F = new HashMap();
                  }

                  var1.p.F.put(this.i, var12);
                  var1.p.G = true;
               }

               var13 = this.n;
               var6 = var13.length;

               for(var7 = 0; var7 < var6; ++var7) {
                  var8 = var13[var7];
                  var1.p.g.get(zyi.a(var8)).getCells().b.a(zyi.b(var8)).a((byte)0);
               }
            }
         }

         if (this.d > -1) {
            var1.g = this.d;
         }

         if (this.e > -1) {
            var1.h = this.e;
         }

         var12 = this.c.e(var1);
         if (this.m != null) {
            if (var10 != null) {
               var1.p.F.put(this.h, var10);
            } else {
               var1.p.F.remove(this.h);
               var1.p.G = var1.p.F.size() > 0;
            }

            var13 = this.m;
            var6 = var13.length;

            for(var7 = 0; var7 < var6; ++var7) {
               var8 = var13[var7];
               var1.p.g.get(zyi.a(var8)).getCells().b.a(zyi.b(var8)).a((byte)0);
            }
         }

         if (this.n != null) {
            if (var11 != null) {
               var1.p.F.put(this.i, var11);
            } else {
               var1.p.F.remove(this.i);
               var1.p.G = var1.p.F.size() > 0;
            }

            var13 = this.n;
            var6 = var13.length;

            for(var7 = 0; var7 < var6; ++var7) {
               var8 = var13[var7];
               var1.p.g.get(zyi.a(var8)).getCells().b.a(zyi.b(var8)).a((byte)0);
            }
         }

         return var12;
      }
   }

   void a(zaay var1) {
      long[] var2;
      int var3;
      int var4;
      long var5;
      if (this.m == null) {
         if (this.n == null) {
            return;
         }

         var1 = new zaay(var1);
         var2 = this.n;
         var3 = var2.length;

         for(var4 = 0; var4 < var3; ++var4) {
            var5 = var2[var4];
            this.a(var1, var5);
         }
      } else {
         var2 = this.m;
         var3 = var2.length;

         for(var4 = 0; var4 < var3; ++var4) {
            var5 = var2[var4];
            this.a(var1, var5);
         }

         if (this.n != null) {
            var2 = this.n;
            var3 = var2.length;

            for(var4 = 0; var4 < var3; ++var4) {
               var5 = var2[var4];
               this.a(var1, var5);
            }
         }
      }

   }

   zgi a(int var1, int var2, int var3, zaay var4, HashMap var5) {
      return new zgj(var1, var2, var3, var4, var5);
   }
}
